package com.astruyk.chordophone;

import android.graphics.Color;

/**
 * Data relating to a chord.
 * 
 * @author Anton Struyk
 */
public class Chord {
	private String _name;
	private String _variant;
	private String _fingeringName;
	private boolean _isCommon;
	private int[] _fingering;
	
	public Chord(
			String name,
			String variant,
			String fingeringName,
			boolean isCommon,
			int[] fingering){
		_name = name;
		_variant = variant;
		_fingeringName = fingeringName;
		_isCommon = isCommon;
		_fingering = fingering;
	}
	
	/**
	 * Gets name to display to the user that identifies this chord.
	 * @return the name of the chord
	 */
	public String getName(){
		return _name;
	}
	
	/**
	 * Gets the variant (chord type) of this chord.
	 * @return a string representing the variant of this chord
	 */
	public String getVariant(){
		return _variant;
	}
	
	/**
	 * Gets an optional name particular to this fingering.
	 * @return
	 */
	public String getFingeringName(){
		return _fingeringName;
	}
	
	/**
	 * Gets a flag that indicates if this fingering should be identified
	 * as a 'common' fingering for this chord.
	 * @return
	 */
	public boolean getIsCommon(){
		return _isCommon;
	}
	
	/**
	 * Gets an array of integers that represent the frets to press on each
	 * string. A value of -1 indicates the string should be muted. The
	 * fingerings are in order from the top of the instrument to the bottom.
	 * @return the frets to press on each string for this chord 
	 */
	public int[] getFingering(){
		return _fingering;
	}
	
	/**
	 * Gets the color to display this chord as in the UI.
	 */
	public int getColor(){
		if(_name.contains("A")){
			return Color.argb(75, 255, 255, 250);
		}else if(_name.contains("B")){
			return Color.argb(75, 225, 225, 225);
		}else if(_name.contains("C")){
			return Color.argb(75, 195, 195, 195);
		}else if(_name.contains("D")){
			return Color.argb(75, 165, 165, 165);
		}else if(_name.contains("E")){
			return Color.argb(75, 135, 135, 135);
		}else if (_name.contains("F")){
			return Color.argb(75, 105, 105, 105);
		}else{
			return Color.argb(75, 75, 75, 75);
		}
	}
	
	/**
	 * Gets a string appropriate for display at the top of a large chord chart.
	 */
	public String getLabelString(){
		return _name + _variant;
	}
	
	@Override
	public String toString(){
		return _name + (_variant.equalsIgnoreCase("major") ? "" : _variant) + " (" + _fingeringName + ")" + (_isCommon ? " - common" : "");
	}
}
